home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ZOOM_EX.ZIP / ZOOM2.ASM < prev   
Assembly Source File  |  1993-12-25  |  6KB  |  279 lines

  1. ;                                                       (C)ode by Nic of IMP
  2.  
  3. JUMPS
  4. SMART
  5. LOCALS
  6. DOSSEG
  7.  
  8. ;───────────────────────────────────────────────────────────────────────────────
  9. ;███████████████████████████████████████████████████████████████████████████████
  10. ;───────────────────────────────────────────────────────────────────────────────
  11.  
  12. Time    =       0       ; to show time equal this to unity
  13.  
  14. ; some usefull macro's
  15.  
  16. ; only for Motorola freaks !
  17.  
  18. movB    MACRO    dst,src
  19.     mov BYTE PTR    dst,src
  20.     ENDM
  21.  
  22. movW    MACRO    dst,src
  23.     mov WORD PTR    dst,src
  24.     ENDM
  25.  
  26. movL    MACRO    dst,src
  27.     mov DWORD PTR    dst,src
  28.     ENDM
  29.  
  30. WaitKey MACRO
  31.     mov    ah,7
  32.     int    21h
  33.     ENDM
  34.  
  35. PrintString MACRO String
  36.     mov    dx,OFFSET String
  37.     mov    ah,9
  38.     int    21h
  39.     ENDM
  40.  
  41. Exit2Dos MACRO    ErrCode
  42.     mov    ax,4c00h+ErrCode
  43.     int    21h
  44.     ENDM
  45.  
  46. Color   MACRO   Num,RComp,GComp,BComp
  47.         push    dx
  48.         push    ax
  49.         mov     dx,3c8h
  50.         mov     al,Num
  51.         out     dx,al
  52.         mov     dx,3c9h
  53.         mov     al,RComp
  54.         out     dx,al
  55.         mov     al,GComp
  56.         out     dx,al
  57.         mov     al,BComp
  58.         out     dx,al
  59.         pop     ax
  60.         pop     dx
  61.         ENDM
  62.  
  63. ;───────────────────────────────────────────────────────────────────────────────
  64. ;███████████████████████████████████████████████████████████████████████████████
  65. ;───────────────────────────────────────────────────────────────────────────────
  66.  
  67. StackSeg    Segment Para USE16 STACK 'STACK'
  68.     DW    512 DUP (?)
  69. StackSeg    Ends
  70.  
  71. ;───────────────────────────────────────────────────────────────────────────────
  72.  
  73. DataSeg     Segment Para USE16 'DATA'
  74.  
  75. CodeString    DB 80 DUP (0)
  76.  
  77.         ALIGN   16
  78. Picture         LABEL
  79.                 INCLUDE TestZoom.pic
  80.                 DB 320 DUP (0)
  81.  
  82. DataSeg     Ends
  83.  
  84. ;═══════════════════════════════════════════════════════════════════════════════
  85.  
  86. CodeSeg     Segment Para USE16 'CODE'
  87.     ASSUME    cs:CodeSeg , ds:DataSeg , ss:StackSeg
  88.  
  89. Prog    Proc Far
  90.     call    SetFree
  91.  
  92.     mov    ax,DataSeg
  93.     mov    ds,ax
  94.     mov    es,ax
  95.     cld
  96.         call    InitGfxMode
  97.         call    InstallColors
  98.  
  99. ;═══════════════════════════════════════════════════════════════════════════════
  100.         call    TstZoom
  101. ;═══════════════════════════════════════════════════════════════════════════════
  102.  
  103.     WaitKey
  104.         call    RestTxtMode
  105.  
  106. Finish: Exit2Dos    0
  107.  
  108. Prog    Endp
  109.  
  110. ;───────────────────────────────────────────────────────────────────────────────
  111. ;███████████████████████████████████████████████████████████████████████████████
  112. ;───────────────────────────────────────────────────────────────────────────────
  113.  
  114. ; here, we'll just make a vertical zoom, it is faster, but it's not for that,
  115. ; I think it will be easier to understant if you have only one zoom & I've
  116. ; tried to keep my code clean & short.
  117.  
  118. OriginalSize    DW      200
  119. DestinationSize DW      0
  120. Count           DW      ?
  121. LineLength      =       320     ; in bytes
  122.  
  123. TabLines        LABEL
  124. ALine   = 0
  125.                 REPT    200
  126.                 DW      ALine
  127. ALine   = ALine + LineLength
  128.                 ENDM
  129.                 REPT    10
  130.                 DW      200*LineLength
  131.                 ENDM
  132.  
  133. TstZoom PROC NEAR
  134.  
  135. VBLLoop:
  136.         mov     dx,3dah         ; wait VBL
  137. Wait1:  in      al,dx
  138.         test    al,8
  139.         jne     Wait1
  140. Wait2:  in      al,dx
  141.         test    al,8
  142.         je      Wait2
  143.  
  144.         IF      Time
  145.         Color   0,20,0,0
  146.         ENDIF
  147.                                 ; Zoom the Pic
  148.         mov     ax,0a000h
  149.         mov     es,ax
  150.         mov     di,0
  151.         inc     DestinationSize
  152.         cmp     DestinationSize,201
  153.         jl      GoodSize
  154.         mov     DestinationSize,1
  155.         call    ClearScreen
  156. GoodSize:
  157.         mov     cx,DestinationSize
  158.         mov     Count,cx
  159.  
  160.         mov     dx,0
  161.         mov     ax,OriginalSize
  162.         mov     bx,DestinationSize
  163.         div     bx                      ; ax = dx:ax / bx
  164.  
  165.         mov     bp,ax
  166.         mov     ax,0
  167.         div     bx
  168.  
  169. ; the 6 following lines are here to make a better approx
  170.         mov     bx,bp
  171.         mov     dx,ax
  172.         shr     bx,1
  173.         rcr     dx,1            ; for approx
  174.         add     dx,08000h
  175.         adc     bx,0            ; + 1/2 for roundness
  176.  
  177. ; increment in          bp:ax
  178. ; starting offset in    bx:dx
  179.  
  180. ZoomLoop:
  181.         mov     si,bx
  182.         add     si,si
  183.         mov     si,TabLines[si]
  184.         add     si,OFFSET Picture
  185.  
  186. CopyOneLine:
  187.         mov     cx,LineLength/2
  188.         REP     movsw
  189.  
  190.         add     dx,ax
  191.         adc     bx,bp
  192.  
  193.         dec     Count
  194.         jnz     ZoomLoop
  195.  
  196.         IF      Time
  197.         Color   0,0,0,0
  198.         ENDIF
  199.                                 ; Zoom the Pic
  200.         in      al,60h          ; read key
  201.         cmp     al,039h
  202.         jne     VBLLoop
  203.  
  204.         ret
  205. TstZoom ENDP
  206.  
  207. ClearScreen PROC NEAR
  208.         mov     ax,0a000h
  209.         mov     es,ax
  210.         mov     ax,0
  211.         mov     cx,320*200/2
  212.         REP     stosw
  213.         ret
  214. ClearScreen ENDP
  215.  
  216. ;───────────────────────────────────────────────────────────────────────────────
  217. ;███████████████████████████████████████████████████████████████████████████████
  218. ;───────────────────────────────────────────────────────────────────────────────
  219.  
  220. ; release memory
  221.  
  222. SetFree PROC NEAR
  223.     mov    bx,ss
  224.     mov    ax,es
  225.     sub    bx,ax
  226.     mov    ax,sp
  227.     add    ax,15
  228.     mov    cl,4
  229.     shr    ax,cl
  230.     add    bx,ax
  231.     mov    ah,4ah
  232.     int    21h
  233.     ret
  234. SetFree ENDP
  235.  
  236. ;───────────────────────────────────────────────────────────────────────────────
  237.  
  238. InstallColors PROC NEAR
  239.         push    ds
  240.         push    cs
  241.         pop     ds
  242.         lea     si,PALETTE
  243.         mov     cx,256
  244.         mov     dx,03c8h
  245.         xor     al,al
  246.         out     dx,al
  247.         inc     dx
  248.         cld
  249. @@ColorLoop:
  250.         lodsb
  251.         shr     al,3
  252.         out     dx,al
  253.         loop    @@ColorLoop
  254.         pop     ds
  255.         ret
  256. InstallColors ENDP
  257.  
  258. PALETTE LABEL
  259.         INCLUDE testzoom.pal
  260.  
  261. InitGfxMode PROC NEAR
  262.         mov     ax,13h
  263.         int     10h
  264.         ret
  265. InitGfxMode ENDP
  266.  
  267. RestTxtMode PROC NEAR
  268.         xor     ah,ah
  269.         mov     al,03h
  270.         int     10h
  271.         ret
  272. RestTxtMode ENDP
  273.  
  274.  
  275. ;═══════════════════════════════════════════════════════════════════════════════
  276.  
  277. CodeSeg     Ends
  278.     END    Prog
  279.